package cn.longge.config;

import cn.longge.interceptor.LoginInterceptor;
import cn.longge.interceptor.ResourceInterceptor;
import org.springframework.context.annotation.*;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import javax.sql.DataSource;

@Configuration
@ComponentScan({"cn.longge.service","cn.longge.aspect"})
@PropertySource(value = "classpath:path.properties",encoding = "utf-8")
@EnableAspectJAutoProxy
public class SpringService {
    @Bean
    public DataSourceTransactionManager getTM(DataSource dataSource){
        return new DataSourceTransactionManager(dataSource);
    }

    @Bean("resourcesInterceptor")
    public ResourceInterceptor getResourcesInterceptor(){
        return new ResourceInterceptor();
    }

    @Bean
    public LoginInterceptor getLoginInterceptor(){
        return new LoginInterceptor();
    }
}
